using System.Threading.Tasks;
using Greet;
using Grpc.Core;
using Microsoft.Extensions.Logging;

namespace Server;

public class ExternalService : External.ExternalBase
{
    private readonly ILogger _logger;

    public ExternalService(ILoggerFactory loggerFactory)
    {
        _logger = loggerFactory.CreateLogger<ExternalService>();
    }

    public override Task<ExternalReply> SayHello(ExternalRequest request, ServerCallContext context)
    {
        _logger.LogInformation($"Sending hello to {request.Name}");
        return Task.FromResult(new ExternalReply { Message = "Hello " + request.Name });
    }
}
